package com.stylefeng.guns.modular.pay.controller.api;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.core.util.AjaxRes;
import com.stylefeng.guns.modular.pay.model.Member;
import com.stylefeng.guns.modular.pay.model.Trans;
import com.stylefeng.guns.modular.pay.service.IMemberService;
import com.stylefeng.guns.modular.pay.service.ITransService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;


/**
 * 会员支付流水相关接口
 * @author Administrator
 *
 */
@Api(value="支付流水业务接口",tags="支付流水业务接口")
@Controller
@RequestMapping("/api/trans/")
public class ApiTransController {
	@Autowired
	private ITransService transService;
	@Autowired
	private IMemberService memberService;
	
	
	@ApiOperation(value="支付流水", notes="根据会员id获取流水")
	@ApiImplicitParams({
		  @ApiImplicitParam(name = "memberId", value = "会员id", required = true, dataType = "String",paramType="path"),
		  @ApiImplicitParam(name = "status", value = "状态", required = true, dataType = "String",paramType="path")
	})
	@RequestMapping(value="/{memberId}/{status}", method=RequestMethod.GET)
	@ResponseBody
	public AjaxRes list(@PathVariable(name="memberId") Integer memberId,@PathVariable(name="status") Integer status){
		Member member = memberService.selectById(memberId);
		if(member==null){
			return new AjaxRes("empty.member", "会员不存在");
		}
		
		List<Trans> transList = transService.selectList(new EntityWrapper<Trans>().eq("mch_no", member.getMemberNo())
				.eq("tran_status", status).orderBy("create_time", false));

		return new AjaxRes(AjaxRes.SUCCESS, "成功",transList);
	}
	

}
